#include "lcd_app.h"

void LCD_printf(uint8_t Line,char *format,...)
{
    char string[21] = {0};
    va_list arg;
    va_start(arg, format);
    vsprintf(string, format, arg);
    va_end(arg);
    LCD_DisplayStringLine(Line, (u8 *)string);
}

uint8_t Show_mode;//0车位显示界面，1费率设置界面
uint8_t Car_state[3]={0,0,8}; // 0为CNBR,1为VNBR,2为IDLE
float charge_rate[2] = {3.50, 2.00};//0为CNBR，1为VNBR的费率
uint8_t clear_mode;//清屏
void lcd_proc(void)
{
    if (!Show_mode)
    {
        if (clear_mode == Show_mode)
        {
            LCD_Clear(Black);
            clear_mode ^= 1;
        }
            LCD_printf(Line1, "       Data ");
            LCD_printf(Line3, "   CNBR:%d  ", Car_state[0]);
            LCD_printf(Line5, "   VNBR:%d  ", Car_state[1]);
            LCD_printf(Line7, "   IDLE:%d  ", Car_state[2]);
    }
    else
    {
        if (clear_mode == Show_mode)
        {
            LCD_Clear(Black);
            clear_mode ^= 1;
        }
        LCD_printf(Line1, "       Para ");
        LCD_printf(Line3, "   CNBR:%.2f  ", charge_rate[0]);
        LCD_printf(Line5, "   VNBR:%.2f  ", charge_rate[1]);
    }

}

